/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package models;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Eduardo
 */
@Entity
@Table(name = "Personal")
@NamedQueries({
    @NamedQuery(name = "Personal.findAll", query = "SELECT p FROM Personal p"),
    @NamedQuery(name = "Personal.findByIdPersonal", query = "SELECT p FROM Personal p WHERE p.idPersonal = :idPersonal"),
    @NamedQuery(name = "Personal.findByFechaReg", query = "SELECT p FROM Personal p WHERE p.fechaReg = :fechaReg"),
    @NamedQuery(name = "Personal.findByFechaFin", query = "SELECT p FROM Personal p WHERE p.fechaFin = :fechaFin"),
    @NamedQuery(name = "Personal.findByEstado", query = "SELECT p FROM Personal p WHERE p.estado = :estado"),
    @NamedQuery(name = "Personal.findByRol", query = "SELECT p FROM Personal p WHERE p.rol = :rol")})
public class Personal implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "IdPersonal")
    private Integer idPersonal;
    @Column(name = "FechaReg")
    @Temporal(TemporalType.DATE)
    private Date fechaReg;
    @Column(name = "FechaFin")
    @Temporal(TemporalType.DATE)
    private Date fechaFin;
    @Column(name = "Estado")
    private Integer estado;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Rol")
    private int rol;
    @ManyToMany(mappedBy = "personalList", fetch = FetchType.LAZY)
    private List<Horarioxlocal> horarioxlocalList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonal", fetch = FetchType.LAZY)
    private List<Donacion> donacionList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonal", fetch = FetchType.LAZY)
    private List<SolicitudCompra> solicitudCompraList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "personal", fetch = FetchType.LAZY)
    private List<Asistencia> asistenciaList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonal", fetch = FetchType.LAZY)
    private List<Incidencia> incidenciaList;
    @JoinColumn(name = "NroDoc", referencedColumnName = "NroDoc")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Persona nroDoc;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonal", fetch = FetchType.LAZY)
    private List<OrdenCompra> ordenCompraList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idPersonal", fetch = FetchType.LAZY)
    private List<Infraccion> infraccionList;

    public Personal() {
    }

    public Personal(Integer idPersonal) {
        this.idPersonal = idPersonal;
    }

    public Personal(Integer idPersonal, int rol) {
        this.idPersonal = idPersonal;
        this.rol = rol;
    }

    public Integer getIdPersonal() {
        return idPersonal;
    }

    public void setIdPersonal(Integer idPersonal) {
        this.idPersonal = idPersonal;
    }

    public Date getFechaReg() {
        return fechaReg;
    }

    public void setFechaReg(Date fechaReg) {
        this.fechaReg = fechaReg;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public Integer getEstado() {
        return estado;
    }

    public void setEstado(Integer estado) {
        this.estado = estado;
    }

    public int getRol() {
        return rol;
    }

    public void setRol(int rol) {
        this.rol = rol;
    }

    public List<Horarioxlocal> getHorarioxlocalList() {
        return horarioxlocalList;
    }

    public void setHorarioxlocalList(List<Horarioxlocal> horarioxlocalList) {
        this.horarioxlocalList = horarioxlocalList;
    }

    public List<Donacion> getDonacionList() {
        return donacionList;
    }

    public void setDonacionList(List<Donacion> donacionList) {
        this.donacionList = donacionList;
    }

    public List<SolicitudCompra> getSolicitudCompraList() {
        return solicitudCompraList;
    }

    public void setSolicitudCompraList(List<SolicitudCompra> solicitudCompraList) {
        this.solicitudCompraList = solicitudCompraList;
    }

    public List<Asistencia> getAsistenciaList() {
        return asistenciaList;
    }

    public void setAsistenciaList(List<Asistencia> asistenciaList) {
        this.asistenciaList = asistenciaList;
    }

    public List<Incidencia> getIncidenciaList() {
        return incidenciaList;
    }

    public void setIncidenciaList(List<Incidencia> incidenciaList) {
        this.incidenciaList = incidenciaList;
    }

    public Persona getNroDoc() {
        return nroDoc;
    }

    public void setNroDoc(Persona nroDoc) {
        this.nroDoc = nroDoc;
    }

    public List<OrdenCompra> getOrdenCompraList() {
        return ordenCompraList;
    }

    public void setOrdenCompraList(List<OrdenCompra> ordenCompraList) {
        this.ordenCompraList = ordenCompraList;
    }

    public List<Infraccion> getInfraccionList() {
        return infraccionList;
    }

    public void setInfraccionList(List<Infraccion> infraccionList) {
        this.infraccionList = infraccionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersonal != null ? idPersonal.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Personal)) {
            return false;
        }
        Personal other = (Personal) object;
        if ((this.idPersonal == null && other.idPersonal != null) || (this.idPersonal != null && !this.idPersonal.equals(other.idPersonal))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "models.Personal[ idPersonal=" + idPersonal + " ]";
    }
    
}
